<template>
  <div class="main">
    <div class="header">
      <div class="title"> <i class="iconfont">&#xe8f4;</i> 最热词表</div>
      <div class="list">
        <TransitionGroup name="list">
          <router-link
          class="item"
          v-for="(item,i) in hotList"
          :class="{first:i===0,second:i===1,third:i===2}"
          :key="item.id"
          :to="{path: 'word', query: {name: item.listname }}"
          >
              <span class="num">{{ i+1 }}</span>
              <span class="listname">{{ item.titlename }}</span>
              <div class="now">{{item.num}}人正在背</div>
          </router-link>
        </TransitionGroup>
      </div>
    </div>
  </div>
</template>
<script>
import { getHotwordlist } from '@/api/rank'
export default {
  name: 'hotWordlistvue',
  data () {
    return {
      hotList: []
    }
  },
  created () {
    getHotwordlist().then((res) => {
      this.hotList = res.data.rank
    })
  }
}
</script>
<style lang="less" scoped>
.main{
  margin-top: 20px;
  height: 450px;
  width: 320px;
  border: 1px solid #e9e9e9;
  background-color: #f1f1f1;
  border-radius: 20px;
  padding: 20px;
  .header{
    height: 40px;
    line-height: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;

    .title{
      height: 40px;
      position: relative;
      font-family: '钉钉进步体';
      font-size: 20px;
      float: left;
      color:#f83e29;
      .iconfont{
        font-size: 20px;
      }
    }

    .list{
      margin-top: 20px;
      margin-left: 20px;
      .item{
        display: block;
        position: relative;
        width: 100%;
        font-size: 16px;
        line-height: 30px;
        height: 30px;
        .now{
          float: right;
          color:#666 ;
          font-size: 8px;
        }
        .num{
          padding-right: 20px;
        }
        .listname{
          cursor: pointer;
          width: 120px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        &:hover{
          color: #3e87e5;
        }
      }
      .first{
        font-family: '钉钉进步体';
        color: rgb(221, 203, 0);
        &:hover{
          color: rgb(251, 230, 2);
        }
      }
      .second{
        font-family: '钉钉进步体';
        color: rgb(134, 134, 134);
        &:hover{
          color: rgb(96, 96, 96);
        }
      }
      .third{
        font-family: '钉钉进步体';
        color: rgb(205, 123, 0);
        &:hover{
          color: rgb(162, 97, 0);
        }
      }

      .list-move, /* 对移动中的元素应用的过渡 */
      .list-enter-active,
      .list-leave-active {
        transition: all 0.5s ease;
      }

      .list-enter-from,
      .list-leave-to {
        opacity: 0;
        transform: translateX(30px);
      }

      /* 确保将离开的元素从布局流中删除
        以便能够正确地计算移动的动画。 */
      .list-leave-active {
        position: absolute;
      }
    }
  }
}

</style>
